#include "StdAfx.h"
#include "SFont.h"

SFont::SFont(void)
{
	m_hFont = 0;
}

SFont::SFont(char * chName, int nSize, bool bBold, bool bItalic, bool bUnderline, bool bStrikeOut)
{
	Init(chName, nSize, bBold, bItalic, bUnderline, bStrikeOut);
}

SFont::~SFont(void)
{
	if (m_hFont != 0)
	{
		DeleteObject(m_hFont);
	}
}

LOGFONT SFont::GetLOGFONT()
{
	LOGFONT LogFont = {0};
	if (m_hFont != 0)
	{
		GetObject(m_hFont, sizeof(LOGFONT), &LogFont);
	}
	return LogFont;
}

void SFont::Init(char * chName, int nSize, bool bBold, bool bItalic, bool bUnderline, bool bStrikeOut)
{
	DWORD nWeight = FW_NORMAL;
	if(bBold) nWeight = FW_BOLD;
	if (nSize > 0)	nSize = -nSize;
	m_hFont = CreateFont(nSize, 0, 0, 0, nWeight, bItalic, bUnderline, bStrikeOut, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, chName);
}